import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { ResouceConst } from "../../../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { ObjCreate } from "../../../common/ObjCreate";
import { Language } from "../../../../../../extend/language/Language";
import { ItemData } from "../../../../resource/info/ItemData";
import { GBox } from "../../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { GImageBitmap } from "../../../../../../com/mui/controls/GImageBitmap";
import { ObjectPool } from "../../../../../../com/gengine/utils/pools/ObjectPool";
import { RuneGuideInfoItem } from "./RuneGuideInfoItem";
import { ScaleBitmap } from "../../../../../../com/mui/display/ScaleBitmap";
import { GButton } from "../../../../../../com/mui/controls/GButton";
type int = number;
//class RuneGuideInfoPanel
    
    export  class RuneGuideInfoPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._runeItems = [0, 12203100, 12203101, 12203102, 12203103];
            this.initUI();
            return;
        }

        /* internal  */onOptClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            dispatchEvent(new DataEvent(EventName.RuneGuideShowItem));
            return;
        }

        protected initUI(): void
        {
            this._bg1 = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._bg1.x = 0;
            this._bg1.y = 0;
            this._bg1.setSize(522, 209);
            addChild(this._bg1);
            this._bg2 = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this._bg2.x = 0;
            this._bg2.y = 211;
            this._bg2.setSize(529, 132);
            addChild(this._bg2);
            this._titleBg = ResouceConst.getScaleBitmap(ImagesConst.TileBg);
            this._titleBg.x = this._bg2.x + 2;
            this._titleBg.y = this._bg2.y + 2;
            this._titleBg.width = 150;
            addChild(this._titleBg);
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 65280, true);
            this._titleTxt = ObjCreate.createTextField("", this._titleBg.x + 20, this._titleBg.y + 2, 100, 20, this, loc1);
            this._titleInfo = ObjCreate.createTextField(Language.getString(26500), this._titleBg.x + 100, this._titleTxt.y + 2, 150, 20, this);
            this._resultTxt = ObjCreate.createTextField(Language.getString(26501), this._titleBg.x + 2, this._bg2.y + 108, 40, 20, this);
            this._resultTxt.textColor = 65280;
            var loc2=new ItemData(this._runeItems[1]);
            this._titleTxt.htmlText = "<font size=\'15\' color=\'#FFFFFF\'>" + loc2.htmlName + "</font>";
            this._box = new GBox();
            this._box.direction = GBoxDirection.HORIZONTAL;
            this._box.x = this._bg2.x + 30;
            this._box.y = this._bg2.y + 37;
            addChild(this._box);
            addChild(new GImageBitmap(ImagesConst.RuneGuideBg, 1, 1));
            this._optBtn = ObjCreate.createGButton(Language.getString(26502), 0, 348, 116, 24, this, "ButtonRed");
            this._optBtn.x = (this.width - this._optBtn.width) / 2;
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptClickHandler);
            this.updateData();
            addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStageHandler);
            return;
        }

        /* internal  */onAddToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.dispose();
            this.updateData();
            return;
        }

        public updateData(): void
        {
            var loc1=0;
            var loc3=null;
            var loc2=this._runeItems.length;
            while (loc1 < loc2) 
            {
                loc3 = ObjectPool.getObject(RuneGuideInfoItem);
                loc3.updateData(this._sourceItem, this._runeItems[loc1], loc1);
                this._box.addChild(loc3);
                ++loc1;
            }
            this._box.invalidate();
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._box.numChildren > 0) 
            {
                loc1 = this._box.removeChildAt(0) as RuneGuideInfoItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1, RuneGuideInfoItem);
            }
            return;
        }

        public /* override */ get width(): number
        {
            return 529;
        }

        /* internal */ /* var */_bg1: ScaleBitmap;

        /* internal */ /* var */_bg2: ScaleBitmap;

        /* internal */ /* var */_titleBg: ScaleBitmap;

        /* internal */ /* var */_titleTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_titleInfo: Object /* flash.text.TextField */;

        /* internal */ /* var */_resultTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_box: GBox;

        /* internal */ /* var */_optBtn: GButton;

        /* internal */ /* var */_sourceItem: int=13003000;

        /* internal */ /* var */_runeItems: Array<any>;
    }
